import Tools from './util/Tools';

// @ts-ignore
type OLMapD = ol.Map;

export default class OLMap {
    // @ts-ignore
    // protected _map: MapOL | null = null;

    public constructor(dom: string) {
        this.init(dom);
        // console.log(olEvents, '==============');
        let tool: Tools = new Tools(1);
    }

    private static init1(dom: string): void {
        // @ts-ignore
        /*new Map({
            target: dom,
            layers: [
                new TileLayer({
                    source:new XYZ({
                        url: 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'
                    })
                })
            ],
            view: new View({
                center: [0, 0],
                zoom: 2
            })
        });*/
    }

    private init(dom: string): void {
        // @ts-ignore
        const projection = ol.proj.get('EPSG:4326');
        // const url = `http://t{0-6}.tianditu.com/DataServer?T=vec_w&tk=a6bf5a2496115f58481b947040c83ae3&x={x}&y={y}&l={z}`;
        const url = `https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png`;
        // @ts-ignore
        const xyzSource = new ol.source.XYZ({
            url,
            wrapX: false
        });
        // 图层
        // @ts-ignore
        const baseLayer = new ol.layer.Tile({
            source: xyzSource
        });

        const centerPoint = [0, 0];

        // @ts-ignore
        this._map = new ol.Map({
            layers: [
                baseLayer
            ],
            target: dom,
            // @ts-ignore
            view: new ol.View({
                center: centerPoint,
                projection,
                zoom: 2,
                maxZoom: 19,
                minZoom: 1
            })
        });
    }
}